package com.chefu.server.controller;


import com.chefu.admin.pojo.ServiceProvider;
import com.chefu.common.pojo.PageResult;
import com.chefu.common.pojo.R;
import com.chefu.server.pojo.Server;
import com.chefu.server.pojo.ServerClassify;
import com.chefu.server.service.ServerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author goodgoodstudy
 * @since 2021-03-30
 */
@RestController
@RequestMapping("/serverManager/server")
public class ServerController {

    @Autowired
    private ServerService serverService;

    /**
     * 查询服务目录列表
     */
    @GetMapping("/page/{pageNum}/{pageSize}")
    public R serverQueryPage(
            @PathVariable("pageNum") Integer pageNum,
            @PathVariable("pageSize") Integer pageSize,
            @RequestParam(value = "serverName",required = false) String serverName,
            @RequestParam(value = "code",required = false) Long code,
            @RequestParam(value = "name",required = false) String name
            ){

        PageResult<Server> serverList = serverService.serverQueryPage(pageNum,pageSize,serverName,code,name);
        return R.ok().data("serverList",serverList);
    }

    /**
     * 根据服务商id查询服务商
     */
    @GetMapping("/of/serviceProvider")
    public R serviceProviderById(@RequestParam("id") Long id){
        ServiceProvider serviceProvider = serverService.serviceProviderById(id);
       return R.ok().data("serviceProvider",serviceProvider);
    }
}

